<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <button onclick=clickA()>点我存储一个值</button>
        <br>
        <span id='top'>123</span>
        <br>
        <button onclick=clickB()>获取一个值</button>
        <br>
        <button onclick=clickC()>清除一个值</button>
        <br>
        <button onclick=clickD()>清除所有值</button>
    </div>

    <script type='text/javascript'>

        const v = [{"key1":"value1"},
                    {"key2":"value2"},
                    {"key3":"value3"},
                    {"key4":"value4"}]

        function clickA(params) {
            localStorage.setItem("key2",JSON.stringify(v))
        }
        function clickB(){
            const json = localStorage.getItem("key2")
            JSON.s
            document.getElementById('top').innerText = str
        }
        function clickC(){
             localStorage.removeItem("key2")
             const str = localStorage.getItem("key2")
             document.getElementById('top').innerText = str
        }
        function clickD(){
            localStorage.clear()
        }
    </script>
    

</body>
</html>